/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.util;

import java.io.File;
import java.io.IOException;
import junit.framework.Assert;
import org.junit.Test;

/**
 *
 * @author Gerben Feenstra
 */
public class FileUtilIT {
    
    @Test
    public void testRemoveTree() throws IOException{
        File testDir = new File("fileUtilTestdir");
        testDir.mkdir();
        
        File newFileInDir = new File(testDir.getPath() + File.separator + "fileInUtilTestdir");
        newFileInDir.createNewFile();
        
        File subDirInTestDir = new File(testDir.getPath() + File.separator + "subdirInUtilTestdir");
        subDirInTestDir.mkdir();
  
        File newFileInSubDir = new File(subDirInTestDir.getPath() + File.separator + "fileInSubdir");
        newFileInSubDir.createNewFile();
        
        
        // Whole tree should be gone
        FileUtil.removeTree(testDir);
        
        System.out.println(newFileInDir.exists());
        
        // Check file-removal
        Assert.assertFalse(newFileInDir.exists());    
        
        // Check file-in-subdir-removal
        Assert.assertFalse(newFileInSubDir.exists()); 
        
        // Check subdir removal
        Assert.assertFalse(subDirInTestDir.exists()); 
    }
}
